package cn.foodProject.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import cn.foodProject.R;
//首页
public class MainActivity extends AppCompatActivity {

    private TextView jump;

    private int Count = 5;
    Handler handler = new Handler();
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            if(Count == 0){
                Intent intent = new Intent(MainActivity.this,LoginActivity.class);
                startActivity(intent);
                finish();
            }
            Count--;
            jump.setText("跳过   "+Count+"s");
            handler.postDelayed(this,1000);
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

        jump.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Count = 0;
            }
        });
        handler.postDelayed(runnable,1000);
    }

    private void initView() {
        jump = (TextView) findViewById(R.id.jump);
    }
}
